package com.example.qxapp.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.qxapp.Bean.User;
import com.example.qxapp.MainActivity;
import com.example.qxapp.R;

import cn.bmob.v3.Bmob;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.BmobUser;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.QueryListener;

public class SettingActivity extends AppCompatActivity {
    private TextView username1,nickname1;
    private Button xgpwd,ghun,tu;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        init();
        ghun.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SettingActivity.this, dlActivity.class));
                finish();
            }
        });

        User user = BmobUser.getCurrentUser(User.class);
        String userid=user.getObjectId();
        BmobQuery<User> us=new BmobQuery<>();
        us.getObject(userid, new QueryListener<User>() {
            @Override
            public void done(User user, BmobException e) {
                if (e==null){
                    username1.setText(user.getUsername());
                    nickname1.setText(user.getNickname());
                }
                else {
                }
            }
    });
        tu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SettingActivity.this, loginActivity.class));
                finish();
            }
        });
    }

    private void init() {
        username1=findViewById(R.id.username1);
        nickname1=findViewById(R.id.nickname1);
        xgpwd=findViewById(R.id.xgpwd);
        ghun=findViewById(R.id.ghun);
        tu=findViewById(R.id.tc);
    }
}
